<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
    <title>Environments</title>
    <link rel="stylesheet" href="gettingStarted.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.62.4" />
    <link rel="home" href="index.html" title="Getting Started with Berkeley DB" />
    <link rel="up" href="introduction.html" title="Chapter 1. Introduction to Berkeley DB " />
    <link rel="previous" href="databaseLimits.html" title="Database Limits and Portability" />
    <link rel="next" href="coreExceptions.html" title="Exception Handling" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">Environments</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="databaseLimits.html">Prev</a> </td>
          <th width="60%" align="center">Chapter 1. Introduction to Berkeley DB </th>
          <td width="20%" align="right"> <a accesskey="n" href="coreExceptions.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="sect1" lang="en" xml:lang="en">
      <div class="titlepage">
        <div>
          <div>
            <h2 class="title" style="clear: both"><a id="environments"></a>Environments</h2>
          </div>
        </div>
        <div></div>
      </div>
      <p>
        This manual is meant as an introduction to the Berkeley DB library.
        Consequently, it describes how to build a very simple, single-threaded
        application. Consequently, this manual omits a great many powerful
        aspects of the DB database engine that are not required by simple
        applications. One of these is important enough that it warrants a brief
        overview here: environments.
    </p>
      <p>
        While environments are frequently not used by applications running in
        embedded environments where every byte counts, they will be used by
        virtually any other DB application requiring anything other than
        the bare minimum functionality. An <span class="emphasis"><em>environment</em></span> is
        essentially an encapsulation of one or more databases. Essentially, you
        open an environment and then you open databases in that environment.
        When you do so, the databases are created/located in a location relative
        to the environment's home directory.
    </p>
      <p>
        Environments offer a great many features that a stand-alone DB
        database cannot offer:
    </p>
      <div class="itemizedlist">
        <ul type="disc">
          <li>
            <p>
                Multi-database files.
            </p>
            <p>
                It is possible in DB to contain multiple databases in a
                single physical file on disk. This is desirable for those
                application that open more than a few handful of databases.
                However, in order to have more than one database contained in 
                a single physical file, your application 
                <span class="emphasis"><em>must</em></span> use an environment. 
            </p>
          </li>
          <li>
            <p>
                Multi-thread and multi-process support
            </p>
            <p>
                When you use an environment, resources such as the in-memory
                cache and locks can be shared by all of the databases opened in the
                environment. The environment allows you to enable
                subsystems that are designed to allow multiple threads and/or
                processes to access DB databases. For example, you use an
                environment to enable the concurrent data store (CDS), the
                locking subsystem, and/or the shared memory buffer pool.
            </p>
          </li>
          <li>
            <p>
                Transactional processing
            </p>
            <p>
                DB offers a transactional subsystem that allows for full
                ACID-protection of your database writes. You use environments to
                enable the transactional subsystem, and then subsequently to obtain
                transaction IDs.
            </p>
          </li>
          <li>
            <p>
                High availability (replication) support
            </p>
            <p>
                DB offers a replication subsystem that enables
                single-master database replication with multiple read-only
                copies of the replicated data. You use environments to enable
                and then manage this subsystem.
            </p>
          </li>
          <li>
            <p>
                Logging subsystem
            </p>
            <p>
                DB offers write-ahead logging for applications that want to
                obtain a high-degree of recoverability in the face of an
                application or system crash. Once enabled, the logging subsystem
                allows the application to perform two kinds of recovery
                ("normal" and "catastrophic") through the use of the information
                contained in the log files.
            </p>
          </li>
        </ul>
      </div>
      <p>
            For more information on these topics, see the
            <i class="citetitle">Berkeley DB Getting Started with Transaction Processing</i> guide and the 
            <i class="citetitle">Berkeley DB Getting Started with Replicated Applications</i> guide.
    </p>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="databaseLimits.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="introduction.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="coreExceptions.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">Database Limits and Portability </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> Exception Handling</td>
        </tr>
      </table>
    </div>
  </body>
</html>
